#define _CRT_SECURE_NO_WARNINGS

#include "String.h"

void test01()
{
	string s1("2338877878788877833");
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	s1 += "hslfhi766666oghshd55tttttttdttttttttttttttttt5555555555fljhgjlhdjfljdlhgldhg7jlsfsdgdsfgsdgdg";
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;
}

void test02()
{
	//TL::string s1("shdisfasflg");
	//cout << s1.size() << endl;
	//cout << s1.capacity() << endl;
	//cout << s1.c_str() << endl;

	////s1.push_back('2');
	//s1.append("shidhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhglishfi");
	//cout << s1.c_str() << endl;
	//cout << s1.size() << endl;
	//cout << s1.capacity() << endl;

	TL::string s1("sghiosd");
	cout << s1.c_str() << endl;

	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	s1 += "shgidshgg";
	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;
}

void test03()
{
	const TL::string s1("hello world");
	/*for (auto& ch : s1)
	{
		ch++;
		cout << ch ;
	}*/
	TL::string::const_iterator it = s1.begin();
	while (it != s1.end())
	{
		//cout << ++(*it);
		cout << *it;

		it++;
	}

	/*const string s1("shighg");
	cout << ++s1[0];*/
}

void test04()
{
	TL::string s1("shiaghs");
	TL::string s2("hello world");
	TL::string s3;

	s3 = s1;
	s2 += "he";
	s1 += 's';
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	cout << s3.c_str() << endl;
}

void test05()
{
	//TL::string s1("shiaghs");
	TL::string s2("hello world");
	//swap(s1, s2);
	//s1.push_back('x');
	//s1.insert(5, 'x');
	//s1.insert(5, "111");
	//s1.append("111sdsf");
	//s1.erase(6,3);
	
	cout << s2.rfind("o") << endl;
	cout << s2.c_str() << endl;
}

void test06()
{
	TL::string s1("hello world");
	s1 += '!';
	cout << s1.c_str() << endl;

	cout << s1.size() << endl;
	cout << s1.capacity() << endl;



	s1.resize(20, 'x');
	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	//s1.append("shigf");
	s1.clear();//s1.size(0);

	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;


}

void test07()
{
	TL::string s1("hello world!");

	size_t pos = s1.find("or");


	TL::string s2 = s1.substr(pos, 3);


	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;

	/*int ret = s1.compare(s2);
	if (ret > 0)
		cout << '>' << endl;
	else if (ret < 0)
		cout << '<' << endl;
	else
		cout << '=' << endl;*/

	int ret = s1.compare("hello world!");
	if (ret > 0)
		cout << '>' << endl;
	else if (ret < 0)
		cout << '<' << endl;
	else
		cout << '=' << endl;
}

void test08()
{
	/*string s1("abcd\0efg");
	string s1("abcd\\0efg");*/
	TL::string s1("hello world!");
	TL::string s2("hello world");

	//getline(cin, s1);
	//cin >> s1;
	
	cout << (s1 == s2) << endl;
	cout << (s1 > s2) << endl;
	cout << (s1 < s2) << endl;
	cout << (s1 >= s2) << endl;
	cout << (s1 <= s2) << endl;
	cout << (s1 != s2) << endl;

}

int main()
{
	test08();
	return 0;
}

//bool isPalindrome(string s)
//{
//	for (auto& e : s)
//	{
//		if (isupper(e))
//		{
//			e += 32;
//		}
//	}
//	size_t begin = 0, end = s.size() - 1;
//	while (begin < end)
//	{
//		while (begin < end && !isalpha(s[end]) && !isdigit(s[end]))
//		{
//			end--;
//		}
//		while (begin < end && !isalpha(s[begin]) && !isdigit(s[begin]))
//		{
//			begin++;
//		}
//		if (begin < end && s[begin] != s[end])
//		{
//			return false;
//		}
//		begin++, end--;
//	}
//	return true;
//}

//int main()
//{
//	string s1("A man, a plan, a canal : Panama");
//	char ch = 'A';
//	tolower(ch);
//	/*if (ret)
//	{
//		cout << "true" << endl;
//	}
//	else
//	{
//		cout << "false" << endl;
//	}*/
//	cout << ch << endl;
//	return 0;
//}


